#  Copyright (c) 2007 re.con team (see README and COPYNG)

require 'yaml'
require 'fileutils'

class Config

  CONFIG =  {
    'dir'    =>  "#{ENV['HOME']}/.recon/",
    'editor' =>  'nano',
    'logfile'=>  'logfile',
    'sites'  =>  {}
  }

  def initialize(filename = File.join( CONFIG['dir'] , 'config'))
    if File.exist?(filename)
      open(filename) {|f| @file_config = YAML.load(f.read) }
    else
      save(filename)
    end
  end

  def save(filename)
    FileUtils.mkdir_p File.dirname(filename) 
    open( filename, 'w' ) {|f| f << CONFIG.to_yaml }
  end
end